package com.zyj.myapplication.Fragment;

/**
 * Created by Administrator on 2017/10/30.
 */

        import android.content.Intent;
        import android.support.v4.app.Fragment;
        import android.os.Bundle;
        import android.support.v7.widget.LinearLayoutManager;
        import android.support.v7.widget.RecyclerView;
        import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;
        import com.zyj.myapplication.Adapter.DashiClassInfoAdapter;
        import com.zyj.myapplication.Javabean.VideoList;
        import com.zyj.myapplication.Model.CoachModel;
        import com.zyj.myapplication.R;
        import java.util.List;
        import retrofit2.Call;
        import retrofit2.Callback;
        import retrofit2.Response;

        import static java.sql.Types.NULL;

public class DashiClassInfoFragment extends Fragment {

    private RecyclerView recyclerView;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.activity_dashi_class_info,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.dashiclass_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        showData();
        return view;
    }
    private void showData(){
        String coach_id=getActivity().getIntent().getStringExtra("coach_id");
        CoachModel coachModel = new CoachModel();
        Call<VideoList> call = coachModel.getVideoList(coach_id,"mvideo");
        call.enqueue(new Callback<VideoList>() {
            @Override
            public void onResponse(Call<VideoList> call, Response<VideoList> response) {
                VideoList mDataList = response.body();
                if(!"".equals(response.body().getMvideo())) {
                    List<VideoList.MvideoBean> vlist = mDataList.getMvideo();
                    recyclerView.setAdapter(new DashiClassInfoAdapter(DashiClassInfoFragment.this.getContext(), vlist));//设置适配器，绑定Adapter.
                }
            }

            @Override
            public void onFailure(Call<VideoList> call, Throwable t) {

            }
        });
    }
}